from flask import Blueprint, request

from swiper.model import Swiper

index_blue = Blueprint('index', __name__)


@index_blue.route('/api/indexswiper', methods=['GET'])
def indexswiper():
    swipers = Swiper.query.all()
    swiper_list = []
    for swiper in swipers:
        if swiper.isshow == 1:
            swiper_list.append({
                'id': swiper.id,
                'image': swiper.image,
                'src': swiper.src,
                'type': 'activity' if swiper.type == 'act' else 'web',
                'activity': swiper.activity
            })
    return {
        'swiper_list': swiper_list
    }, 200